Improve Action trait #15
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR introduces some recommended changes for the
Action
trait based on what I encountered while finishing the implementation of action clients and servers in rclrs. When theAction
trait was first introduced to the library, it was largely inspired by how the template implementation ofrclcpp_action
works. This was reasonable for the most part, but some aspects don't line up perfectly with what makes the most sense in practical Rust.Here are the changes introduced by this PR and their motivation:
ActionImpl
is removed. The C++ templates have a separation of public API and private API for details related to the implementation of actions. This makes sense from a software engineering perspective, and it would be nice to have a clean separation in rclrs as well, but in practice I found that it didn't accomplish anything. Because of how generics work in Rust, I wound up needing to use the trait boundA: ActionImpl
everywhere inrclrs
, to the point that theAction
trait was never used. At that point I figured we're not achieving a separation anyway if we need to useActionImpl
everywhere, so we may as well roll it all into simplyAction
.split_
instead ofget_
methods. Various action service messages consist of two fields mashed together into one message, and we need to use associated functions to separate those fields. The currentmain
uses methods that give back a borrow of each field, but this forces a.clone()
which can be avoided by splitting the message instead of borrowing it. In practice I found no value in borrowing the fields while implementing actions services and clients.Rmw...
type aliases. These type aliases were declaredpub
but were inaccessible outside of the crate because of how thetrait
module was set up. These aliases are useful inrclrs
, so I've updated thepub use traits
to include everything in the module. I saw no reason to cherry-pick the module contents.This PR is a dependency of ros2-rust/rosidl_rust#7 and ros2-rust/ros2_rust#503